// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()

const db = cloud.database();
const col = db.collection('two');
const _ = db.command;

// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()

  // 查询该用户在数据库中的记录
  let user = await col.where({
    '_openid': wxContext.OPENID
  }).get();

let username=event.username;
let phonenumber=event.phonenumber;
let addr=event.addr;

  let result = await col.where({
    '_openid': wxContext.OPENID
  }).update({
    data: {
      username:username,
      phonenumber:phonenumber,
      addr:addr
    }
  });
  return {
    msg:"提交用户信息成功",
    result:result
  }
}